home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 7 / FM Towns Free Software Collection 7.iso / t_os / bb / src / parmode.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-11-30  |  2.7 KB  |  137 lines

  1. /*
  2.  
  3.         parent mode text array make
  4.  
  5.                       1993.6.27 v1.0
  6.                       copyright Y.Ouchi
  7.  
  8.             input    *intext   : log analize result
  9.                     *disptext : display text array
  10.  
  11.             output    same as input
  12.  
  13. */
  14.  
  15. #include    <string.h>
  16. #include    <stdlib.h>
  17. #include    "bb.h"
  18.  
  19.     /* 関数プロトタイプ宣言 */
  20. void    parset(struct logcontent *, int, int, short *);
  21.  
  22. extern    int        max_textp;
  23.  
  24. static    int        textp;
  25. static    int        comlevel;
  26.  
  27. void    parmode(struct logcontent *intext,short *disptext)
  28. {
  29.     int        i,j,leng,nextp;
  30.     int        startp=0;
  31.     int        nowtext;
  32.     char    nowtitle[8];
  33.     int        nowmesno;
  34.     char    *workp;
  35.  
  36.     nowtitle[0]=0x00;
  37.     nowmesno=0;
  38.     comlevel=0;
  39.     textp=0;
  40.     nextp=0;
  41.     while (nextp<intext->maxtext){
  42.         for (i=nextp;i<intext->maxtext;i++){
  43.             if (intext->text[i].text.id==TITLE_ID){
  44.                 workp=&intext->text[i].title.a;
  45.                 for (j=0;j<8;j++) nowtitle[j]=workp[j];
  46.                 nowmesno=intext->text[i].title.mes_no;
  47.                 disptext[textp++]=i;
  48.             }
  49.             else{
  50.                 if (intext->text[i].text.id==NOTITLE_TEXT_ID){
  51.                     disptext[textp++]=i;
  52.                 }
  53.                 else{
  54.                     startp=i;
  55.                     break;
  56.                 }
  57.             }
  58.         }
  59.  
  60.         leng=1;
  61.         for (i=startp+1;i<intext->maxtext;i++){
  62.             if (intext->text[i].title.id==TITLE_ID){
  63.                 if (strcmp(nowtitle,&intext->text[i].title.a)!=0
  64.                         || intext->text[i].title.mes_no!=nowmesno){
  65.                     workp=&intext->text[i].title.a;
  66.                     for (j=0;j<8;j++) nowtitle[j]=workp[j];
  67.                     nowmesno=intext->text[i].title.mes_no;
  68.                     break;
  69.                 }
  70.                 else disptext[textp++]=i;
  71.             }
  72.             leng=leng+1;
  73.         }
  74.         nextp=startp+leng;
  75.  
  76.         nowtext=0;
  77.         while ( leng>0 ){
  78.             switch (intext->text[startp+nowtext].text.id){
  79.                 case TITLE_ID :
  80.                     break;
  81.                 case NOTITLE_TEXT_ID :
  82.                     disptext[textp++]=startp+nowtext;
  83.                     break;
  84.                 default :
  85.                     if (intext->text[startp+nowtext].text.work==0){
  86.                         parset(intext,startp+nowtext,leng,disptext);
  87.                     }
  88.                     break;
  89.             }
  90.             nowtext=nowtext+1;
  91.             leng=leng-1;
  92.         }
  93.     }
  94.     max_textp=textp;
  95.     return;
  96. }
  97.  
  98. /*
  99.         parent text set (recursive call)
  100.                       1993.6.09 v.00
  101.                       copyright Y.Ouchi
  102.  
  103.             input        text
  104.                         text number
  105.                         length
  106.             output        nothing
  107.  
  108. */
  109.  
  110. void parset(struct logcontent *intext, int sp, int len, short *dispt)
  111. {
  112.     int        i,textnosave;
  113.  
  114.     comlevel=comlevel+1;
  115.     dispt[textp++]=sp;
  116.     textnosave=intext->text[sp].text.text_no;
  117.     i=1;
  118.     len=len-1;
  119.     while ( len>0 ) {
  120.         switch (intext->text[sp+i].text.id){
  121.             case TEXT3C_ID :
  122.             case TEXT5C_ID :
  123.                 if (intext->text[sp+i].text.com_no==textnosave
  124.                             && intext->text[sp+i].text.work==0){
  125.                     intext->text[sp+i].text.work=comlevel;
  126.                     parset(intext,sp+i,len,dispt);
  127.                 }
  128.                 break;
  129.         }
  130.         i=i+1;
  131.         len=len-1;
  132.     }
  133.     comlevel=comlevel-1;
  134.     return;
  135. }
  136.  
  137.